package domfarr.spring.jpa;

import java.util.List;

import javax.persistence.EntityManagerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.jpa.support.JpaDaoSupport;
import org.springframework.stereotype.Component;

@Component
public class UserDao extends JpaDaoSupport {

	@Autowired
	public UserDao(EntityManagerFactory entityManagerFactory) {
		setEntityManagerFactory(entityManagerFactory);
	}
	
	@SuppressWarnings("unchecked")
	public List<User> findByLastName(String lastName) {
		List list = getJpaTemplate().findByNamedQuery(User.FIND_USER_BY_LAST_NAME, lastName);
		
		return list;
	}

}
	